package com.hdjk.view.callback;

import android.text.TextUtils;

import com.lst.projectlib.entity.Msg;
import com.zhy.http.okhttp.callback.Callback;

import org.json.JSONObject;

import java.io.IOException;

import okhttp3.Response;

/**
 * Created by Admin on 2017/10/13.
 */

public abstract class LogoutCallback extends Callback<Msg> {
    @Override
    public Msg parseNetworkResponse(Response response, int id)
            throws IOException {
        Msg msg = new Msg();

        try {
            String result = response.body().string();

            if (!TextUtils.isEmpty(result)) {
                JSONObject rootObject = new JSONObject(result);

                msg.setSuccess(rootObject.getString("State").equals("1"));
                msg.setMsg(rootObject.getString("Msg"));
            }
        } catch (Exception e) {
        }

        return msg;
    }
}